package com.wzxy.pf.bill.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzxy.pf.bill.dto.BillDTO;
import com.wzxy.pf.bill.entity.Bill;
import com.wzxy.pf.bill.mapper.BillMapper;
import com.wzxy.pf.bill.service.BillService;
import org.springframework.stereotype.Service;

@Service
public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements BillService {
    @Override
    public Page<Bill> selectBillsByPage(BillDTO billDTO) {
        //构建page对象
        Page<Bill> objectPage = new Page<>(billDTO.getPageNo(), billDTO.getPageSize());
        //构建wrapper查询条件
        QueryWrapper<Bill> objectQueryWrapper = new QueryWrapper<>();
        //编号
        String billType = billDTO.getBillType();
        String typeName = billDTO.getTypeName();
        String billTime = billDTO.getBillTime();
        objectQueryWrapper.eq(StringUtils.isNotBlank(billType),"bill_type",billType);
        objectQueryWrapper.eq(StringUtils.isNotBlank(typeName),"type_name",typeName);
        objectQueryWrapper.eq(StringUtils.isNotBlank(billTime),"bill_time",billTime);
        //执行分页查询
        Page<Bill> page = this.page(objectPage, objectQueryWrapper);
        return page;
    }
}
